package top.yxqz.listener.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @author Mr.余
 * @date 2022/12/8
 * @package top.yxqz.listener.web
 * 监听application域的监听器
 */
@WebListener
public class SayHelloServletContextListener  implements ServletContextListener {

    /**
     * 监听初始化 application域对象产生
     */
    @Override
    public void contextInitialized(ServletContextEvent event) {
        ServletContext servletContext = event.getServletContext(); //得到当前产生的域对象
        servletContext.setAttribute("People_number",0); //初始化数据
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
